package com.fxu.framework.core.enums;

import com.fasterxml.jackson.annotation.JsonCreator;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 语言枚举
 * @author fangxu
 * @version 2025-06-05
 */
@Getter
@AllArgsConstructor
public enum LanguageEnum {
    ZH_CN("zh_CN", "zh", "中文"),
    EN_US("en_US", "en", "英文"),
    ZH_HK("zh_HK", "cht", "繁体"),
    ZH_TW("zh_TW", "cht", "繁体"),
    FR_FR("fr_FR", "fra", "法文"),
    MN_MN("mn_MN", "mn", "蒙古文"),
    ;

    private String code;
    private String field;
    private String desc;

    @JsonCreator
    public static LanguageEnum find(String code) {
        return code == null ? ZH_CN : Arrays.stream(values()).filter(v -> v.getCode().equalsIgnoreCase(code))
                .findFirst().orElse(ZH_CN);
    }
}
